package com.neusoft.mapper;

import com.neusoft.po.Orders;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DeliverymanMapper {

    @Select("SELECT distinct OrderNumber FROM `delivery` WHERE OrdersState = 0")
    public List<Integer> listNonAcceptedOrders();

    @Select("SELECT distinct OrderNumber FROM `delivery` WHERE userId = #{userId} AND OrdersState = 1" )
    public List<Integer> listAcceptedOrderByDeliverymanId(String userid);

    @Update("UPDATE `delivery` SET OrdersState = 1, userId = #{userId} WHERE OrderNumber = #{OrderNumber} AND OrdersState = 0")
    public int AcceptedOrders(@Param("OrderNumber") int OrderNumber, @Param("userId")String userId);

    @Update("UPDATE `delivery` SET OrdersState = 2 WHERE OrderNumber = #{OrderNumber} AND OrdersState = 1")
    public int FinishedOrders(int OrderNumber);
}
